home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PROGEDIT
/
3458B.ZIP
/
AMAC44B.ZIP
/
SR.QM
< prev
next >
Wrap
Text File
|
1992-06-22
|
8KB
|
175 lines
* SR.QM
* Search/Replace From Command Line Using SR.BAT and SZR.BAT
* 6/8/92
*
* ----------------------------------------------------------------------
* @(0) Search/Replace From Command Line Using SR.BAT and SZR.BAT,
* Can Also Remove Search Text
* ----------------------------------------------------------------------
* This macro performs a search/replace of both text files and text
* files within zip files. It is the autoexecutable macro to perform a
* search/replace from the command line only using two batch files:
* - SR.BAT Search/Replace Text Files
* - SZR.BAT Search/Replace Text Files Within Zip Files
* Withoout Having to Manually Unzip and Rezip
* This version of this macro is a modification of previous versions of
* SR.QM that now enables the user to also REMOVE search text by hitting
* <enter> at the replacement text prompt, in addition to specified text
* replacement. Versions included with Amac43.zip and prior required
* that some replacement text (Non-empty) be entered at the replacement
* text prompt.
* FGREP.COM, INPUT.COM and QEdit v2.15 are required. Changing c:\ to
* you ram drive will increase speed. Please refer to SR.BAT and SZR.BAT
* for other details concerning entering optional parameters at the
* command line or in response to input query prompts.
* SRCH.TST file is included to demonstrate use of this macro replacing
* text in text files.
* As an example, at the command line enter the following commands:
* 1. "sr" <enter>
* 2. "sss" space "ttt" <enter> (answer SEARCH text prompt)
* 3. "SSS" space "TTT" <enter> (answer REPLACEMENT text prompt)
* 4 "srch.tst" <enter> (answer FileList prompt)
* When completed, the following files remain loaded for viewing or
* editing:
* Window 1 c:\! List of files found & search text by line
* Window 2 n+1 Files containing search text with replacements
* (n = # files containing search text)
* Temporary file names are:
* c:\$.ql List of files found & search text (output from FGREP.COM)
* c:\! Same as c:\$.ql
* c:\$ Output of Dos SET
@0 macrobegin
setsoundoff
altwordset * For all file names
cursordown cursorup
jtrue START * Test if any search text found
* --------------- Display "No found text" Message ---------------*
MESSAGE:
"No found text" *|
jump END * If not found, display this
* -------------------------- Load Files --------------------------*
START:
endfile
LOADAGAIN:
* unmarkblock * Unmark last file name *|
setscreenon setscreenoff * To reduce flashing
find
#42 "Fi" return
"B" return * Find file name
jfalse MESSAGE * No find ?, show message, end
wordright wordright
markcolumn endline copy * Copy file name to scrap
EditFile
CurrentFilename " "
Paste Return * Load file
cursorup
jtrue LOADAGAIN * Test if more filenames?
* ------------------ Get Search Text To Scratch ------------------*
editfile "c:\$" return * Load set output file
find
"S~~" return
delline return * Find S~~ in SET output
find
"=" return
delline return * Move to =
cursorright markcharacter * Mark first character
endline * Move to end of text
storescrbuff "S~~" return * Store SEARCH text to scratch
* ----------------- Get Replace Text To Scratch -----------------*
unmarkblock begfile
find
"R~~" return
delline return * Find R~~
jtrue FOUND * If found, we specified replacement text*|
endline markcolumn * If not, make empty block to clear buff *|
jump BLANK *|
FOUND: *|
find
"=" return
delline return * Move to =
cursorright markcharacter * Mark first character
endline * Move to end of text
BLANK: *|
storescrbuff "R~~" return * Store REPLACE text to scratch
* killfile quit * Kill/quit c:\$ *|
* ---------------------- Do Search/Replace ----------------------*
* Editfile "NUL" Return * Load NUL File *|
getscrbuff "S~~" return
cut * Cut search text from scratch
Find paste Return escape * Initialize find prompt
getscrbuff "R~~" return
cut * Cut replace text from scratch
FindReplace
return paste return * Begin replacement
"GIN" * Replace options
* pause ** Add this to pause for options
return * MUST include "GIN"
killfile quit * Kill/quit c:\$ *|
* ---------------- Load Files, Do Search/Replace ----------------*
Begfile Cursorright * Put cursor in col 2 of c:\! *|
* Begline Cursorright * Put cursor in Col. 2 of NUL File *|
setscreenon *|
LOOP: * Main test loop
Nextfile
Cursorleft Jfalse DOIT
Cursorleft Jfalse ENDLOOP
DOIT: * FindReplace Loop
BegFile * Move up in case cursor is below find
Repeatfind * Do the FindReplace
Jtrue SAVE * If CHANGES are made -- SAVE the File
Quit * If NO CHANGES are made -- QUIT the file
Jump LOOP * Return to the Main Loop
SAVE: * Routine to Save a File with Changes
Savefile * Save the file
Jump LOOP * Return to Main Loop
ENDLOOP: * Loop is DONE
* getscrbuff "R~~" return * Get replacement text from scratch *|
* cut * Cut replace text from scratch *|
* Quit * Quit the NUL File *|
Find
paste return
delline return * Initialize Find for f4
begfile
END:
* EditFile "c:\!" Return * Load FGREP.COM output as first file *|
defaultwordset
*
* 153 bytes Tue 10-02-1990 18:50:33
* 223 bytes Thu 04-25-1991 11:57:13 added find initialize for search
* added "GIN" replace option
* added "No found text" message
* changed file "_" to "NUL", faster
* load FGREP.COM output as first file
* after replacement
* 231 bytes Tue 04-30-1991 22:12:13
* 234 bytes Wed 04-15-1992 17:25:02 (TH @0, for QEdit v2.15)
* (In Amac42e.zip)
* 236 bytes Tue 05-12-1992 12:55:13 (TH @0, changed Find initialization)
* (In Amac43.zip)
* 213 bytes Mon 06-01-1992 17:07:07 (TH @0, will remove search text *|)
* (f4)
f4 repeatfind
* (f5)
f5 prevfile
* (f6)
f6 nextfile